﻿namespace King.Learn.DoNet.CSharp11.Example
{
    public record struct Point(decimal X, decimal Y) : ICanAdd<Point>
    {
        /// <summary>
        /// 隐式实现接口方法
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static Point operator +(Point left, Point right)
        {
            return new Point(left.X + right.X, left.Y + right.Y);
        }

        /// <summary>
        /// 显式实现接口方法
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        static Point ICanAdd<Point>.operator +(Point left, Point right)
        {
            return new Point(left.X + right.X, left.Y + right.Y);
        }
    }
}